/*
 PMCreateProfileViewController.h
 Date Created: February 16, 2010
 
 Author: Karol Krizka <kkrizka@gmail.com>
 
 Copyright (C) 2010 Green-Power
 
 URL: http://code.google.com/p/green-power
 
 This program is free software; you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
 the Free Software Foundation; either version 3 of the License, or
 (at your option) any later version.
 
 This program is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.
 
 You should have received a copy of the GNU General Public License
 along with this program; if not, write to the Free Software
 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 
 $Id$
 */

#import <UIKit/UIKit.h>

#import "PMProfileList.h"

/**
 * Controls the view used for creating a new profile. It presents the view, and 
 * waits for the user to press the create button. After the create button is
 * pressed, the profile is added to the profile list and the view is hidden.
 *
 * Only allows creation of valid profile names that are unique.
 */
@interface PMCreateProfileViewController : UIViewController<UITextFieldDelegate> {
  UITextField *profileNameTextField;
  UIButton *createProfileButton;
  PMProfileList *profileList;
}


@property (nonatomic,retain) IBOutlet UITextField *profileNameTextField;
@property (nonatomic,retain) IBOutlet UIButton *createProfileButton;

@property (nonatomic,retain) PMProfileList *profileList;

/**
 * Constructor that creates the create profile view controller.
 *
 * \param profileList The profile list that the new profile should be inserted into
 */
- (PMCreateProfileViewController *)initWithProfileList:(PMProfileList *)profileList;

/**
 * Checks if the characters entered into the UITextField for profile name are alphanumeric
 * or whitespace.
 *
 * \param textField Reference to the UITextField for profile name
 * \param range The range that is being edited
 * \param string The new string being entered
 *
 * \return YES if the string is valid, no otherwise.
 */
- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string;

/**
 * Indicates what should happen when the enter button is pressed. For now, just hide the keyboard.
 *
 * \return Always returns YES
 */
- (BOOL)textFieldShouldReturn:(UITextField *)textField;

/**
 * Checks if the entered text is valid. If it is, then enable the create button
 *
 * \param sender The source of the event
 */
- (IBAction)textFieldTextChanged:(id)sender;

/**
 * Creates the profile
 *
 * \param sender The source of the event
 */
- (IBAction)createProfile:(id)sender;

@end
